﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI;
using YArchitech.BIM;
using YArchitech.Controls;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.Revit;

namespace YArchitech.HYSpace
{
	public partial class FrmCreatSpaceByRoom : System.Windows.Forms.Form
	{
		public FrmCreatSpaceByRoom()
		{
			this.InitializeComponent();
			this.SetToolTip();
		}

		public FrmCreatSpaceByRoom(ExternalCommandData commandData)
		{
			this.InitializeComponent();
			base.Icon = Resource.YArchitechIcon;
			this.btnAdd.Image = Resources.AddNew16;
			this.btnModify.Image = Resources.modify16;
			this.btnDelete.Image = Resources.delete16;
			this.commData = commandData;
			this.SetToolTip();
		}

		private void SetToolTip()
		{
			this.dgvRoomKeyInfo.ShowCellToolTips = false;
			this.toolTip1.AutomaticDelay = 0;
			this.toolTip1.OwnerDraw = true;
			this.toolTip1.ShowAlways = true;
			this.toolTip1.ToolTipTitle = "Custom Tooltip: ";
			this.toolTip1.UseAnimation = false;
			this.toolTip1.UseFading = false;
		}

		private void FrmCreatSpaceByRoom_Load(object sender, EventArgs e)
		{
			this.loadParam = new LoadParamOperate();
			FrmCreatSpaceByRoom.listRKTS = SpaceParameterOperate.GetAllRoomKeyInfo(this.loadParam.GetAllRoomUse());
			foreach (RoomKeyToSpace roomKeyToSpace in FrmCreatSpaceByRoom.listRKTS)
			{
				roomKeyToSpace.Opetation = "无操作";
			}
			BindingSource bindingSource = new BindingSource();
			bindingSource.DataSource = FrmCreatSpaceByRoom.listRKTS;
			bindingSource.ResetBindings(true);
			this.dgvRoomKeyInfo.DataSource = bindingSource;
		}

		private void btnDelete_Click(object sender, EventArgs e)
		{
			int rowCount = this.dgvRoomKeyInfo.RowCount;
			if (rowCount == 1)
			{
				YJKMessageBox.Show("请至少保留一条信息！");
				return;
			}
			if (YJKMessageBox.Show("确定要删除此信息？", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
			{
				RoomKeyToSpace roomKeyToSpace = new RoomKeyToSpace();
				int count = this.dgvRoomKeyInfo.SelectedRows.Count;
				if (count >= rowCount)
				{
					YJKMessageBox.Show("请至少保留一条信息！");
					return;
				}
				int num = 0;
				int num2 = 0;
				List<RoomKeyToSpace> list = new List<RoomKeyToSpace>();
				for (int i = 0; i < count; i++)
				{
					num2 = this.dgvRoomKeyInfo.SelectedRows[i].Index;
					roomKeyToSpace.RoomKey = Convert.ToString(this.dgvRoomKeyInfo.SelectedRows[i].Cells["ColRoomNameKey"].Value);
					roomKeyToSpace.KeyId = Convert.ToString(this.dgvRoomKeyInfo.SelectedRows[i].Cells["ColKeyId"].Value);
					roomKeyToSpace.RoomUseId = Convert.ToInt32(this.dgvRoomKeyInfo.SelectedRows[i].Cells["ColSpaceId"].Value);
					roomKeyToSpace.RoomUseName = Convert.ToString(this.dgvRoomKeyInfo.SelectedRows[i].Cells["ColSpaceType"].Value);
					roomKeyToSpace.Opetation = Convert.ToString(this.dgvRoomKeyInfo.SelectedRows[i].Cells["ColOperation"].Value);
					num++;
					RoomKeyToSpace item = new RoomKeyToSpace();
					foreach (RoomKeyToSpace roomKeyToSpace2 in FrmCreatSpaceByRoom.listRKTS)
					{
						if (roomKeyToSpace2.KeyId == roomKeyToSpace.KeyId)
						{
							item = roomKeyToSpace2;
							list.Add(item);
							if (roomKeyToSpace2.Opetation != "添加")
							{
								roomKeyToSpace2.Opetation = "删除";
								this.listDeleteRKTS.Add(item);
								break;
							}
							break;
						}
					}
				}
				foreach (RoomKeyToSpace item2 in list)
				{
					FrmCreatSpaceByRoom.listRKTS.Remove(item2);
				}
				BindingSource bindingSource = new BindingSource();
				bindingSource.DataSource = FrmCreatSpaceByRoom.listRKTS;
				bindingSource.ResetBindings(true);
				this.dgvRoomKeyInfo.DataSource = bindingSource;
				if (num2 > 1)
				{
					this.dgvRoomKeyInfo.ClearSelection();
					this.dgvRoomKeyInfo.Rows[0].Selected = true;
					return;
				}
			}
		}

		private void dgvRoomKeyInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
		{
			DataGridView dataGridView = this.dgvRoomKeyInfo;
			string value = this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColSpaceType"].Value.ToString();
			if (dataGridView.Columns[e.ColumnIndex].Name == "ColSpaceType" && e.RowIndex >= 0 && e.RowIndex < dataGridView.Rows.Count)
			{
				FrmShowInfoGrid frmShowInfoGrid = new FrmShowInfoGrid(Convert.ToInt32(this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColSpaceId"].Value), "CONTINUE");
				if (frmShowInfoGrid.ShowDialog() == DialogResult.Yes)
				{
					foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfoGrid.listSPI)
					{
						if (spaceParameterInfo.RoomId == frmShowInfoGrid.selRoomId)
						{
							this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColSpaceId"].Value = frmShowInfoGrid.selRoomId;
							this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColSpaceType"].Value = spaceParameterInfo.RoomTypeName + "-" + spaceParameterInfo.RoomName;
							if (this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColSpaceType"].Value.ToString().Equals(value))
							{
								break;
							}
							if (this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColOperation"].Value.ToString() != "添加")
							{
								this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColOperation"].Value = "修改";
								break;
							}
						}
					}
				}
			}
		}

		private void btnAdd_Click(object sender, EventArgs e)
		{
			this.dgvRoomKeyInfo.Columns["ColRoomNameKey"].ReadOnly = false;
			this.dgvRoomKeyInfo.Columns["ColSpaceType"].ReadOnly = false;
			RoomKeyToSpace roomKeyToSpace = new RoomKeyToSpace();
			roomKeyToSpace.KeyId = Guid.NewGuid().ToString().ToUpper();
			roomKeyToSpace.Opetation = "添加";
			roomKeyToSpace.RoomKey = "新房间";
			roomKeyToSpace.RoomUseId = Convert.ToInt32(this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColSpaceId"].Value);
			roomKeyToSpace.RoomUseName = Convert.ToString(this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColSpaceType"].Value);
			FrmCreatSpaceByRoom.listRKTS.Add(roomKeyToSpace);
			BindingSource bindingSource = new BindingSource();
			bindingSource.DataSource = FrmCreatSpaceByRoom.listRKTS;
			bindingSource.ResetBindings(true);
			this.dgvRoomKeyInfo.DataSource = bindingSource;
			int num = 0;
			foreach (object obj in ((IEnumerable)this.dgvRoomKeyInfo.Rows))
			{
				DataGridViewRow dataGridViewRow = (DataGridViewRow)obj;
				if (Convert.ToString(dataGridViewRow.Cells["ColKeyId"].Value) == FrmCreatSpaceByRoom.listRKTS.Last<RoomKeyToSpace>().KeyId)
				{
					num = dataGridViewRow.Index;
				}
			}
			this.dgvRoomKeyInfo.ClearSelection();
			this.dgvRoomKeyInfo.Rows[num].Selected = true;
			this.dgvRoomKeyInfo.Rows[num].Visible = true;
			this.dgvRoomKeyInfo.FirstDisplayedScrollingRowIndex = num;
			this.dgvRoomKeyInfo.CurrentCell = this.dgvRoomKeyInfo.Rows[num].Cells["ColRoomNameKey"];
			this.dgvRoomKeyInfo.BeginEdit(true);
		}

		private string GetNowTime()
		{
			string str = DateTime.Now.Year + "-";
			string str2 = DateTime.Now.Month + "-";
			string str3 = DateTime.Now.Day + "-";
			string str4 = DateTime.Now.ToString("HH-mm-ss-");
			return str + str2 + str3 + str4;
		}

		private int GetFourRandomNum()
		{
			int num = -1;
			int num2 = -1;
			int num3 = -1;
			Random random = new Random();
			int num4 = random.Next(1, 9);
			while (num == -1 || num == num4)
			{
				num = random.Next(0, 9);
			}
			while (num2 == -1 || num2 == num4 || num2 == num)
			{
				num2 = random.Next(0, 9);
			}
			while (num3 == -1 || num3 == num4 || num3 == num || num3 == num2)
			{
				num3 = random.Next(0, 9);
			}
			return num4 * 1000 + num * 100 + num2 * 10 + num3;
		}

		private void btnModify_Click(object sender, EventArgs e)
		{
			this.dgvRoomKeyInfo.Columns["ColRoomNameKey"].ReadOnly = false;
			this.dgvRoomKeyInfo.Columns["ColSpaceType"].ReadOnly = false;
			this.dgvRoomKeyInfo.CurrentCell = this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColRoomNameKey"];
			this.dgvRoomKeyInfo.BeginEdit(true);
			this.dgvRoomKeyInfo.SelectedRows[0].Cells["ColOperation"].Value = "修改";
		}

		private void btnSure_Click(object sender, EventArgs e)
		{
			try
			{
				this.Save_Click(sender, e);
				this.btnCreatSpace_Click(sender, e);
			}
			catch (Exception)
			{
				throw;
			}
		}

		private string CheckRoomsOfPreject()
		{
			string result = "";
			FilteredElementIterator elementIterator = new HYSystemElementFilter(this.commData.Application.ActiveUIDocument.Document).GetElementsByBICategory(BuiltInCategory.OST_Rooms).GetElementIterator();
			elementIterator.Reset();
			List<Element> list = new List<Element>();
			while (elementIterator.MoveNext())
			{
				if (elementIterator.Current != null && elementIterator.Current is Room)
				{
					list.Add(elementIterator.Current);
				}
			}
			if (list.Count < 1)
			{
				return "项目内没有房间，\n请创建房间后，\n再执行创建空间命令！";
			}
			return result;
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void btnCreatSpace_Click(object sender, EventArgs e)
		{
			try
			{
				UIApplication application = this.commData.Application;
				UIDocument activeUIDocument = application.ActiveUIDocument;
				Document document = activeUIDocument.Document;
				Transaction transaction = new Transaction(document, "创建空间");
				transaction.Start();
				SpaceParameterOperate.CreatSpaceShareParam(application);
				SpaceParameterOperate.CreatLoadParaShareInfo(application);
				IList<Element> elementByCategory = YJKElementFilter.GetElementByCategory(document, BuiltInCategory.OST_MEPSpaces);
				IList<Space> list = new List<Space>();
				IList<Space> list2 = new List<Space>();
				foreach (Element element in elementByCategory)
				{
					Space space = element as Space;
					if (space != null && space.GetBoundarySegments(new SpatialElementBoundaryOptions()).Count > 0)
					{
						list.Add(space);
					}
				}
				foreach (Element element2 in ((IEnumerable<Element>)YJKElementFilter.GetElementByCategory(document, BuiltInCategory.OST_Rooms)))
				{
					Room room = element2 as Room;
					if (room != null && !YJKRevitTools.isExsitSpace(room, list))
					{
						list2.Add(YJKRevitTools.CreatSpace(document, room));
					}
				}
				string text = "";
				Dictionary<Room, Transform> linkAllRoom = this.GetLinkAllRoom(application, ref text);
				if (!string.IsNullOrEmpty(text))
				{
					YJKMessageBox.Show(text + "链接模型丢失！\n其链接内房间，\n不能创建空间！");
				}
				if (linkAllRoom != null)
				{
					IList<Level> list3 = new List<Level>();
					foreach (KeyValuePair<Room, Transform> keyValuePair in linkAllRoom)
					{
						if (keyValuePair.Key != null && !YJKRevitTools.isExsitSpace(keyValuePair.Key, list))
						{
							Space space2 = YJKRevitTools.CreatSpace(document, keyValuePair.Key, keyValuePair.Value, ref list3);
							if (space2 != null)
							{
								list2.Add(space2);
							}
						}
					}
				}
				document.Regenerate();
				this.loadParam = new LoadParamOperate();
				IList<SpaceParameterInfo> allSpaceInfo = this.loadParam.GetAllSpaceInfo();
				FrmCreatSpaceByRoom.listRKTS = SpaceParameterOperate.GetAllRoomKeyInfo(this.loadParam.GetAllRoomUse());
				List<RoomKeyToSpace> creatSpaceToKey = SpaceParameterOperate.GetCreatSpaceToKey(FrmCreatSpaceByRoom.listRKTS);
				RevitVersionFuncs.ClearSelection(activeUIDocument.Selection);
				IList<Element> elementByCategory2 = YJKElementFilter.GetElementByCategory(document, BuiltInCategory.OST_HVAC_Zones);
				int num = 0;
				foreach (Space space3 in list2)
				{
					if (space3 != null)
					{
						num++;
						SpaceParameterInfo spaceParameterInfo = null;
						int spaceTypeNameByKey = SpaceParameterOperate.GetSpaceTypeNameByKey(creatSpaceToKey, space3.Name);
						Parameter parameter = space3.GetParameter("关键字空间类型ID");
						if (spaceTypeNameByKey > 0)
						{
							foreach (SpaceParameterInfo spaceParameterInfo2 in allSpaceInfo)
							{
								if (spaceParameterInfo2.RoomId == spaceTypeNameByKey)
								{
									spaceParameterInfo = spaceParameterInfo2;
								}
							}
							parameter.Set(spaceTypeNameByKey.ToString());
						}
						else
						{
							spaceParameterInfo = allSpaceInfo[0];
							parameter.Set(spaceParameterInfo.RoomId.ToString());
						}
						List<string> allLoadParaName = SpaceParameterOperate.GetAllLoadParaName();
						SpaceParameterOperate.SetSpaceParaemeter(spaceParameterInfo, space3, allLoadParaName);
						SpaceParameterOperate.SetSpaceParaValue(spaceParameterInfo, space3);
						RevitVersionFuncs.AddToSelection(activeUIDocument.Selection, space3);
						this.AddSpacesToZone(document, ref elementByCategory2, spaceParameterInfo, space3);
					}
				}
				if (num > 0)
				{
					YJKMessageBox.Show("成功创建" + num + "个空间");
				}
				if (list2.Count < 1 && elementByCategory.Count > 0)
				{
					YJKMessageBox.Show("当前项目没有需要创建空间的房间");
				}
				if (list2.Count < 1 && elementByCategory.Count < 1)
				{
					YJKMessageBox.Show("当前项目内没有搜索\n到房间，无法创建空间！\n(请检查当前项目或者\n链接项目是否创建房间,\n以及链接模型是否丢失)");
				}
				transaction.Commit();
				base.Close();
			}
			catch (Exception)
			{
				throw;
			}
		}

		private void AddSpacesToZone(Document doc, ref IList<Element> ListZone, SpaceParameterInfo spi, Space item)
		{
			bool flag = false;
			IList<Element> list = new List<Element>();
			foreach (Element element in ListZone)
			{
				Zone zone = element as Zone;
				list.Add(zone);
				string name = zone.Name;
				if (!zone.IsDefaultZone && zone != null)
				{
					if (zone.Spaces.IsEmpty)
					{
						doc.Delete(zone.Id);
						list.Remove(zone);
					}
					else if (name == spi.RoomTypeName + "-" + spi.RoomName)
					{
						SpaceSet spaceSet = new SpaceSet();
						spaceSet.Insert(item);
						zone.AddSpaces(spaceSet);
						flag = true;
					}
				}
			}
			ListZone = list;
			if (!flag)
			{
				Zone zone2 = SpaceParameterOperate.CreatZoneSetParaBySpace(doc, spi.RoomTypeName + "-" + spi.RoomName, spi);
				SpaceSet spaceSet2 = new SpaceSet();
				spaceSet2.Insert(item);
				zone2.AddSpaces(spaceSet2);
				ListZone.Add(zone2);
			}
		}

		private void AddZoneSpaces(Dictionary<Zone, int> dicZone, IList<Space> listSpace)
		{
			foreach (KeyValuePair<Zone, int> keyValuePair in dicZone)
			{
				SpaceSet spaceSet = new SpaceSet();
				foreach (Space space in listSpace)
				{
					if (space != null)
					{
						int num = Convert.ToInt32(space.GetParameter("关键字空间类型ID").AsString());
						if (keyValuePair.Value == num)
						{
							spaceSet.Insert(space);
						}
					}
				}
				keyValuePair.Key.AddSpaces(spaceSet);
			}
		}

		public Dictionary<Room, Transform> GetLinkAllRoom(UIApplication uiApp, ref string linkName)
		{
			Dictionary<Room, Transform> dictionary = new Dictionary<Room, Transform>();
			Document document = uiApp.ActiveUIDocument.Document;
			FilteredElementCollector elementsOfType = YJKElementFilter.GetElementsOfType(document, typeof(Instance), BuiltInCategory.OST_RvtLinks);
			IList<string> linkFilePaths = YJKRevitTools.GetLinkFilePaths(document);
			foreach (Element element in elementsOfType)
			{
				Instance instance = element as Instance;
				if (instance != null)
				{
					Transform totalTransform = instance.GetTotalTransform();
					(document.GetElement(instance.GetTypeId()) as RevitLinkType).GetParameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set(1);
					string value = instance.Name.Substring(0, instance.Name.IndexOf(".rvt"));
					string text = "";
					foreach (string text2 in linkFilePaths)
					{
						if (text2.Contains(value))
						{
							text = text2;
						}
					}
					if (File.Exists(text))
					{
						FilteredElementCollector filteredElementCollector = new FilteredElementCollector(uiApp.Application.OpenDocumentFile(text));
						filteredElementCollector.OfCategory(BuiltInCategory.OST_Rooms);
						new List<double>();
						new List<double>();
						IEnumerator<Element> enumerator3 = filteredElementCollector.GetEnumerator();
						{
							while (enumerator3.MoveNext())
							{
								Element element2 = enumerator3.Current;
								Room room = element2 as Room;
								if (room.Location != null)
								{
									dictionary.Add(room, totalTransform);
								}
							}
							continue;
						}
					}
					int length = instance.Name.IndexOf(":");
					linkName = linkName + instance.Name.Substring(0, length) + "\n";
				}
			}
			return dictionary;
		}

		private bool JudgeProjectLevel(List<double> listLevel, List<double> listLinkLevel)
		{
			bool result = false;
			foreach (double item in listLinkLevel)
			{
				if (!listLevel.Contains(item))
				{
					result = true;
					break;
				}
			}
			return result;
		}

		private void dgvRoomKeyInfo_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
		{
			DataGridView dataGridView = (DataGridView)sender;
			if (dataGridView.Columns[e.ColumnIndex].Name == "ColSpaceType" || e.RowIndex < 0 || e.RowIndex >= dataGridView.Rows.Count)
			{
				e.Cancel = true;
				return;
			}
			this.oldkeyName = dataGridView.Rows[e.RowIndex].Cells["ColRoomNameKey"].Value.ToString();
		}

		private void dgvRoomKeyInfo_CellEndEdit(object sender, DataGridViewCellEventArgs e)
		{
			if (e.RowIndex < 0 || e.RowIndex >= this.dgvRoomKeyInfo.Rows.Count)
			{
				return;
			}
			if (this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColRoomNameKey"].Value == null)
			{
				return;
			}
			if (string.IsNullOrEmpty(this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColRoomNameKey"].Value.ToString()))
			{
				this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColRoomNameKey"].Selected = true;
				return;
			}
			string a = this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColOperation"].Value.ToString();
			string b = this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColKeyId"].Value.ToString();
			foreach (RoomKeyToSpace roomKeyToSpace in FrmCreatSpaceByRoom.listRKTS)
			{
				if (roomKeyToSpace.KeyId == b)
				{
					roomKeyToSpace.RoomKey = Convert.ToString(this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColRoomNameKey"].Value);
					roomKeyToSpace.RoomUseId = Convert.ToInt32(this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColSpaceId"].Value);
					roomKeyToSpace.RoomUseName = Convert.ToString(this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColSpaceType"].Value);
				}
			}
			if (a != "添加")
			{
				if (this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColRoomNameKey"].Value.ToString().Equals(this.oldkeyName))
				{
					return;
				}
				this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColOperation"].Value = "修改";
			}
		}

		private void dgvRoomKeyInfo_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
		{
			if (base.ActiveControl == this.btnCancle)
			{
				return;
			}
			if (e.RowIndex >= this.dgvRoomKeyInfo.Rows.Count)
			{
				return;
			}
			if (this.dgvRoomKeyInfo.Rows[e.RowIndex].Cells["ColSpaceType"].ColumnIndex == e.ColumnIndex || e.RowIndex < 0)
			{
				return;
			}
			if (this.dgvRoomKeyInfo.Columns[e.ColumnIndex].Name == "ColRoomNameKey")
			{
				if (e.FormattedValue == null || string.IsNullOrEmpty(e.FormattedValue.ToString()))
				{
					MessageBox.Show("关键词不能为空！", "盈建科提示");
					e.Cancel = true;
				}
				foreach (object obj in ((IEnumerable)this.dgvRoomKeyInfo.Rows))
				{
					DataGridViewRow dataGridViewRow = (DataGridViewRow)obj;
					string[] array = e.FormattedValue.ToString().Split(new char[]
					{
						',',
						'，'
					});
					if (dataGridViewRow.Index != e.RowIndex && dataGridViewRow.Cells[e.ColumnIndex].Value != null)
					{
						foreach (string b in dataGridViewRow.Cells[e.ColumnIndex].Value.ToString().Split(new char[]
						{
							',',
							'，'
						}))
						{
							string[] array3 = array;
							for (int j = 0; j < array3.Length; j++)
							{
								if (array3[j] == b)
								{
									YJKMessageBox.Show("关键字不能重复！");
									e.Cancel = true;
									return;
								}
							}
						}
					}
				}
			}
		}

		private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
		{
			e.Graphics.FillRectangle(Brushes.AliceBlue, e.Bounds);
            e.Graphics.DrawRectangle(Pens.White, new System.Drawing.Rectangle(0, 0, e.Bounds.Width - 1, e.Bounds.Height - 1));
			e.Graphics.DrawString(e.ToolTipText, e.Font, Brushes.Black, e.Bounds);
		}

		private void dgvRoomKeyInfo_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
		{
			this.toolTip1.Hide(this.dgvRoomKeyInfo);
		}

		private void Save_Click(object sender, EventArgs e)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			foreach (RoomKeyToSpace roomKeyToSpace in FrmCreatSpaceByRoom.listRKTS)
			{
				string opetation = roomKeyToSpace.Opetation;
				if (!(opetation == "添加"))
				{
					if (opetation == "修改")
					{
						roomKeyToSpace.Opetation = "无操作";
						SpaceParameterOperate.UpdataRoomKeyInfo(roomKeyToSpace);
						num2++;
					}
				}
				else
				{
					roomKeyToSpace.Opetation = "无操作";
					SpaceParameterOperate.AddRoomKeyInfo(roomKeyToSpace);
					num++;
				}
			}
			foreach (RoomKeyToSpace roomKeyToSpace2 in this.listDeleteRKTS)
			{
				SpaceParameterOperate.DeleteRoomKeyInfo(roomKeyToSpace2.KeyId);
				num3++;
				roomKeyToSpace2.Opetation = "无操作";
			}
			this.listDeleteRKTS = new List<RoomKeyToSpace>();
			if (num > 0 || num2 > 0 || num3 > 0)
			{
				string text = "";
				if (num > 0)
				{
					text = string.Concat(new object[]
					{
						text,
						"添加",
						num,
						"条数据"
					});
				}
				if (!string.IsNullOrEmpty(text))
				{
					text += "\n";
				}
				if (num2 > 0)
				{
					text = string.Concat(new object[]
					{
						text,
						"修改",
						num2,
						"条数据"
					});
				}
				if (!string.IsNullOrEmpty(text))
				{
					text += "\n";
				}
				if (num3 > 0)
				{
					text = string.Concat(new object[]
					{
						text,
						"删除",
						num3,
						"条数据"
					});
				}
				YJKMessageBox.Show(text);
			}
		}

		private ExternalCommandData commData;

		private static List<RoomKeyToSpace> listRKTS;

		private string oldkeyName;

		private LoadParamOperate loadParam;

		private List<RoomKeyToSpace> listDeleteRKTS = new List<RoomKeyToSpace>();
	}
}
